<?php

class OWOX_Functions_BaseFunctions extends MinkTestCase
{

    protected function setUp()
    {
        $driver = $this -> getSelenium2Driver();
        $this -> _getSession($driver);
        parent::setUp();
    }

    protected function tearDown()
    {
        parent::tearDown();
        $this -> session -> stop();
    }

    /**
     * @param url
     * @return void
     */

    public function openPage($url)
    {
        $this -> session -> resizeWindow(1000, 1200);
        $this -> session -> visit($url);
        $this -> session -> wait(1000);
    }

    /**
     * @param locator,value
     * @return void
     */

    public function fillField($locator, $value)
    {
        $field = $this -> _findElement($locator);
        $field -> setvalue($value);
        $this -> assertEquals($field -> getValue(), $value);
    }

    /**
     * @param locator
     * @return void
     */

    public function pressButton($locator)
    {
        $this -> session -> getPage() -> find("xpath", $locator) -> click();
    }

    /**
     * @param locator, time
     * @return void
     */

    public function pressButtonAndWait($locator, $time)
    {
        $this -> pressButton($locator);
        $this -> session -> wait($time);
    }

    /**
     * @param locator, message
     * @return void
     */

    public function elementHere($locator, $message)
    {
        $element = $this -> session -> getPage() -> find("xpath", $locator);
        $this -> assertNotNull($element , $message);
    }

    /**
     * @param locator, message
     * @return void
     */

    public function elementNotHere($locator, $message)
    {
        $element  = $this -> session -> getPage() -> find("xpath", $locator);
        $this -> assertNull($element , $message);
    }

    /**
     * @param locator,expected value, message
     * @return void
     */

    public function textValidation($locator, $expected_value, $message)
    {
        $actual_value = $this -> session -> getPage() -> find("xpath", $locator) -> getText();
        $this -> assertEquals($actual_value, $expected_value, $message);
    }

    /**
     * @return array
     */

    public function ForDataProvider($data)
    {
        $file_sites = file('/owox/engine/master/tests/engine/OWOX/Sites/' . $data);

        foreach ($file_sites as &$value) {

            $value = array($value);

        }

        return $file_sites;

    }

}